package com.dotflat.check.domain.C.PO;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import javax.xml.bind.JAXBException;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Date;
import java.util.List;

@Data
@XmlRootElement(name = "GetClassListInfoResult")  // 父节点名称
@XmlAccessorType(XmlAccessType.FIELD) //定义这个类中的何种类型需要映射到XML
public class GetClassListInfoResultPO {

    @JSONField(name = "AuditState")
    Integer AuditState = 0;
    @JSONField(name = "Capacity")
    Integer Capacity = 0;
    @JSONField(name = "ClassCardNo")
    String ClassCardNo = "";
    @JSONField(name = "ClassCategory")
    Integer ClassCategory = 0;
    @JSONField(name = "ClassDes")
    String ClassDes = "";
    @JSONField(name = "ClassFullName")
    String ClassFullName = "";
    @JSONField(name = "ClassInfoID")
    Integer ClassInfoID = 0;
    @JSONField(name = "ClassName")
    String ClassName   = "";;
    @JSONField(name = "ClassStage")
    Integer ClassStage = 1;
    @JSONField(name = "ClassType")
    Integer ClassType = 1;
    @JSONField(name = "CreateDate")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
    Date CreateDate;
    @JSONField(name = "Creator")
    String Creator = "";
    @JSONField(name = "DispayOrder")
    Integer DispayOrder = 0;
    @JSONField(name = "KgId")
    Integer KgId = 0;
    @JSONField(name = "State")
    Integer State = 1;
    @JSONField(name = "UpDate")
    String UpDate;
    @JSONField(name = "Updator")
    String Updator;


    /**
     * 将对象转为流程XML
     *
     * @return
     * @throws JAXBException
     */
    public static String convertToXML(List<GetClassListInfoResultPO> list) {
        String data = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
                "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n" +
                "    <soap:Body>\n" +
                "        <GetClassListInfoResponse xmlns=\"http://tempuri.org/\">\n" +
                "            <GetClassListInfoResult>${v}</GetClassListInfoResult>\n" +
                "        </GetClassListInfoResponse>\n" +
                "    </soap:Body>\n" +
                "</soap:Envelope>";
        String xmlStr = JSON.toJSONString(list);
        data = data.replace("${v}", xmlStr);
        return data;
    }

}
